﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using LogLib;

namespace IDCardReader
{
    public class IDCardInfo
    {      
        public byte[] pucIIN = new byte[4];
        public byte[] pucSN = new byte[8];
        public byte[] pucCHMsg = new byte[512];	//文字信息
        public byte[] pucPHMsg = new byte[1024];	//照片信息
        public byte[] pucFPMsg = new byte[1024];	//指纹信息 
        public int uiCHMsgLen;
        public int uiPHMsgLen;
        public int uiFPMsgLen;

        public string m_IDname;
        public string m_IDsex;
        public string m_IDborn;
        public string m_IDadd;
        public string m_IDnation;
        public string m_IDCARDNO;
        public string m_IDdepartment;
        public string m_IDdate;
        public string m_IDNO;
        public string m_pcPHMsgFileName;
        public string m_BmpFilePathName;
        public string m_PngFilePathName;

        private void ClearArray(byte[] dataArr)
        {
            Array.Clear(dataArr, 0, dataArr.Length);
        }

        public void Reset()
        {
            ClearArray(pucIIN);
            ClearArray(pucSN);
            ClearArray(pucCHMsg);
            ClearArray(pucPHMsg);
            ClearArray(pucFPMsg);
           
            uiCHMsgLen = 0;
            uiPHMsgLen = 0;
            uiFPMsgLen = 0;

            m_IDname = "";
            m_IDsex = "";
            m_IDborn = "";
            m_IDadd = "";
            m_IDnation = "";
            m_IDCARDNO = "";
            m_IDdepartment = "";
            m_IDdate = "";
            m_IDNO = "";
       
            Action<string> delFun = (string path) => 
            {
                if (File.Exists(path))
                {
                    try
                    {
                        File.Delete(path);
                    }
                    catch (Exception ex)
                    {
                        Log.WriteException(ex.ToString());
                    }
                }
            };

           // delFun(m_pcPHMsgFileName);
           // delFun(m_BmpFilePathName);
           // delFun(m_PngFilePathName);

            m_pcPHMsgFileName = "";
            m_BmpFilePathName = "";
            m_PngFilePathName = "";
        }
    }
}
